home *** CD-ROM | disk | FTP | other *** search
Wrap
// ********************************************************************** // * CustDetail.js JavaScript Development by Burgeonet.com * // * Development Started 12-10-2000 * // ********************************************************************** // ---====**** Begin code section for Customer Detail display ****====--- // ********************************************************************** // * Establish array variables. These must match the * // * Customer Detail Variables as per the CustDetail.htm page. * // * * // * Mr/Mrs/Miss/Ms Salute * // * First name FirstName * // * Initials Initials * // * Last Name LastName * // * Company Name Comp Name * // * Address Address * // * Address2 Address2 * // * Post Code PoCode * // * Telephone CustTele * // * * // * 1 2 3 4 5 6 7 8 9 10 11 12 13 * // * Delimitor characters ñ ª º ½ ¼ ║ ╗ ┐ ╢ ▐ ° ^ * // * * // ********************************************************************** var Salute = new Array(); var FirstName = new Array(); var Initials = new Array(); var LastName = new Array(); var CompName = new Array(); var Address = new Array(); var Address2 = new Array(); var PoCode = new Array(); var CustTele = new Array(); // ----------------------------- End ---------------------------------- // ----====****Begin shared cookie functions****====---- // ********************************************************************** // * Global expdate variable for cookies * // * Cookie is set to expire in 24 hours * // ********************************************************************** var expdate = new Date(); expdate.setTime (expdate.getTime() + (365 * 24 * 60 * 60 * 1000)) // ----------------------------- End ---------------------------------- // ********************************************************************** // * Read cookie data. * // ********************************************************************** function getCookieData(name) { var label = name + "=" var labelLen = label.length var cLen = document.cookie.length var i = 0 while (i < cLen) { var j = i + labelLen if (document.cookie.substring(i,j) == label) { var cEnd = document.cookie.indexOf(";",j) if (cEnd == -1) { cEnd = document.cookie.length } return unescape(document.cookie.substring(j,cEnd)) } i++ } return "" } // ----------------------------- End ---------------------------------- // ********************************************************************** // * Write cookie data. * // ********************************************************************** function setCookieData(name,value,expires) { counter ++ document.cookie = name + "=" + counter + "@" + value + "; expires=" + expires + "; Path=" + "/" } // ----------------------------- End ---------------------------------- // ********************************************************************** // * Kill cookie function. * // ********************************************************************** function killCookie(name) { if (getCookieData(name)) { document.cookie = name + "=" + "; expires = Thu, 01-Jan-70 00:00:01 GMT" + ";path = /" cookData = "" counter = 0 //history.go(0) } } // ----------------------------- End ---------------------------------- // ----====**** End shared cookie functions ****====---- // ********************************************************************** // * Begin code section to update the cookie to * // * add items to the shopping cart cookie 'Scart'. * // ********************************************************************** // ----====**** Global variables. ****====---- var counter = 0 var cookData = "" // ********************************************************************** // * Extract current value of cookie when page loads * // * and store the values in the global variables. * // ********************************************************************** if (getCookieData("Detail")) { orderString = getCookieData("Detail") cLen = orderString.length countEnd = orderString.indexOf("@") pointer = countEnd + 1 counter = orderString.substring(0,countEnd) cookData = orderString.substring(pointer,cLen) } // ----------------------------- End ---------------------------------- // ********************************************************************** // * Function to add details to the Details Cookie. * // * To ensure that there is only ever one set of details * // * any previous cookie is deleted before the new info is applied * // ********************************************************************** function addinfo() { killCookie("Detail") addDetail = '' + Salute + '¼' + FirstName + '║' + Initials + '╗' + LastName + '┐' + CompName + '╢' + Address + '▐' + Address2 + ' ' + PoCode + '°' + CustTele + '^' //addCart = '' + a + '`' + itemDesc[num] + '~' + price[num] + '½' + itemQty[num] + '^' cookData += eval("addDetail") if (confirm("Add Details to Cookie")) { setCookieData("Detail", cookData, expdate.toGMTString()) } } // ----------------------------- End ---------------------------------- // ----====**** End code section for updating the cookie. ****====---- // ********************************************************************** // * Debugging function to display cookie contents. * // ********************************************************************** function showMe() { if (getCookieData("Detail") == "") alert("Cookie Blank"); else { alert("ShowMe" + getCookieData("Detail")); } } // ----------------------------- End ---------------------------------- // ********************************************************************** // * Builds an array of the items to load the cart. * // ********************************************************************** function orderDetail(Idx,Sal,Fir,Ini,Lnm,Com,Adda,Addb,Pcde,Ctel) { Salute[Idx] = Sal FirstName[Idx] = Fir Initials[Idx] = Ini LastName[Idx] = Lnm CompName[Idx] = Com Address[Idx] = Adda Address2[Idx] = Addb PoCode[Idx] = Pcde CustTele[Idx] = Ctel } // ----------------------------- End ---------------------------------- // ********************************************************************** // * Function to parse the cookie and extract the ordered * // * items from the string. This in turn triggers the * // * writeCart() function to display the shopping cart. * // ********************************************************************** function DetailsStored() { //addDetail = '' + Salute + '¼' + FirstName //+ '║' + Initials + '╗' + LastName + '┐' + CompName + '╢' + Address + '▐' + Address2 //+ ' ' + PoCode + '°' + CustTele if (getCookieData("Detail")) { substr0 = getCookieData("Detail") cLen = substr0.length offset0 = substr0.indexOf("@") counter = substr0.substring(0,offset0) j = 0 for (i=1; i<=counter; i++) { offsetq = eval('offset' + j + ''); substrq = eval('substr' + j + ''); eval('ind' + i + ' = offsetq + 1'); eval('substr' + i + ' = substrq.substring(ind' + i + ',cLen)'); eval('offset' + i + ' = substr' + i + '.indexOf("^")'); eval('item' + i + ' = substr' + i + '.substring(0,offset' + i + ')'); // Salutation eval('SalutInd' + i + ' = item' + i + '.indexOf("¼")'); eval('Salut' + i + ' = item' + i + '.substring(0,SalutInd' + i + ')'); // First Name eval('FirstInd' + i + ' = item' + i + '.indexOf("║")'); eval('FirstNam' + i + ' = item' + i + '.substring((SalutInd' + i + ' + 1),FirstInd' + i + ')'); // Initials eval('InitialInd' + i + ' = item' + i + '.indexOf("╗")'); eval('Initials' + i + ' = item' + i + '.substring((FirstInd' + i + ' + 1),InitialInd' + i + ')'); // Last Name eval('LastNamInd' + i + ' = item' + i + '.indexOf("┐")'); eval('LastNam' + i + ' = item' + i + '.substring((InitialInd' + i + ' + 1),LastNamInd' + i + ')'); // Company Name eval('CompNamInd' + i + ' = item' + i + '.indexOf("╢")'); eval('CompNam' + i + ' = item' + i + '.substring((LastNamInd' + i + ' + 1),CompNamInd' + i + ')'); // Address eval('AddInd' + i + ' = item' + i + '.indexOf("▐")'); eval('Add' + i + ' = item' + i + '.substring((CompNamInd' + i + ' + 1),AddInd' + i + ')'); // Address2 eval('Add2Ind' + i + ' = item' + i + '.indexOf(" ")'); eval('Add2' + i + ' = item' + i + '.substring((AddInd' + i + ' + 1),Add2Ind' + i + ')'); // Postal Code eval('PoCdeInd' + i + ' = item' + i + '.indexOf("°")'); eval('PoCde' + i + ' = item' + i + '.substring((Add2Ind' + i + ' + 1),PoCdeInd' + i + ')'); // Telephone eval('CustTel' + i + ' = item' + i + '.substring((PoCdeInd' + i + ' + 1),offset' + i + ')'); eval('orderDetail(i,Salut' + i + ',FirstNam' + i + ',Initials' + i + ',LastNam' + i +',CompNam' + i + ',Add' + i +',Add2' + i +',PoCde' + i +',CustTel' + i +')'); j++ } WriteDetails(); } } // ------------------------ End Cookie Reader ------------------ // ----====**** $$$ ****====---- // ----====**** End Customer Detail cookie code. ****====---- // ********************************************************************** // * Function to Print the Detail Form * // ********************************************************************** function WriteDetails() { Ndx = 1 document.write('<FORM NAME="Detail"> ' + ' <TABLE WIDTH="466" BORDER="1" BORDERCOLOR="#000096" CELLSPACING="0"' + ' CELLPADDING="0" BGCOLOR="#000096"> ' + ' <TR> ' + ' <TD><B><FONT COLOR="#FFFFCC" FACE="Verdana,Arial,Helvetica"' + ' SIZE="2">Customer Details</FONT></B></TD> ' + ' <TD><FONT FACE="verdana,Arial,helvetica" SIZE="1"' + ' COLOR="#FFFFCC"><B>Customer / Account Address</B></FONT></TD> ' + ' </TR> ' + ' </TABLE> ' + ' <TABLE WIDTH="450" BORDER="0" CELLSPACING="0" CELLPADDING="0"' + ' BGCOLOR="#FFFFFF"> ' + ' <TR> ' + ' <TD ALIGN="CENTER"> <FONT FACE="verdana" SIZE="1">Please enter your' + ' details below.</FONT> </TD> ' + ' </TR> ' + ' </TABLE> ' + ' <BR> ' + ' <TABLE WIDTH="466" BGCOLOR="#FFFFFF" BORDER="1" BORDERCOLOR="#000000"' + ' CELLPADDING="0" CELLSPACING="0"> ' + ' <TR> ' + ' <TD HEIGHT="5" ALIGN="CENTER"> ' + ' <TABLE WIDTH="100%" BORDER="0" CELLPADDING="1" CELLSPACING="0"> ' + ' <TR VALIGN="MIDDLE">' + ' <TD WIDTH="160" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#000096"> </TD>' + ' <TD WIDTH="9" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"> </TD>' + ' <TD WIDTH="296" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"> </TD>' + ' </TR>' + ' <TR VALIGN="MIDDLE"> ' + ' <TD WIDTH="160" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#000096"><B><FONT FACE="verdana,Arial,helvetica" SIZE="1"' + ' COLOR="#FFFFCC">Mr/ Mrs Miss/ Ms.</FONT></B></TD> ' + ' <TD WIDTH="9" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"></TD> ' + ' <TD WIDTH="296" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"><FONT COLOR="#FFFFCC"><INPUT TYPE="TEXT" NAME="Text9"' + ' SIZE="4" MAXLENGTH="4" VALUE="' + Salute[Ndx] + '"></FONT></TD> ' + ' </TR> ' + ' <TR VALIGN="MIDDLE"> ' + ' <TD WIDTH="160" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#000096"><B><FONT FACE="verdana,Arial,helvetica" SIZE="1"' + ' COLOR="#FFFFCC">First Name</FONT></B></TD> ' + ' <TD WIDTH="9" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"></TD> ' + ' <TD WIDTH="296" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"><FONT COLOR="#FFFFCC"><INPUT TYPE="TEXT" NAME="Text1"' + ' VALUE="' + FirstName[Ndx] + '"></FONT></TD> ' + ' </TR> ' + ' <TR VALIGN="MIDDLE"> ' + ' <TD WIDTH="160" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#000096"><B><FONT FACE="verdana,Arial,helvetica" SIZE="1"' + ' COLOR="#FFFFCC">Initials</FONT></B></TD> ' + ' <TD WIDTH="9" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"></TD> ' + ' <TD WIDTH="296" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"><FONT COLOR="#FFFFCC"><INPUT TYPE="TEXT" NAME="Text2"' + ' SIZE="5" MAXLENGTH="10" VALUE="' + Initials[Ndx] + '"></FONT></TD> ' + ' </TR> ' + ' <TR> ' + ' <TD WIDTH="160" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#000096"><B><FONT FACE="verdana,Arial,helvetica" SIZE="1"' + ' COLOR="#FFFFCC">Last Name</FONT></B></TD> ' + ' <TD WIDTH="9" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"></TD> ' + ' <TD WIDTH="296" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"><FONT COLOR="#FFFFCC"><INPUT TYPE="TEXT" NAME="Text3"' + ' SIZE="35" MAXLENGTH="35" VALUE="' + LastName[Ndx]+ '"></FONT></TD> ' + ' </TR> ' + ' <TR> ' + ' <TD WIDTH="160" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#000096"><B><FONT FACE="verdana,Arial,helvetica" SIZE="1"' + ' COLOR="#FFFFCC">Company Name</FONT></B></TD> ' + ' <TD WIDTH="9" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"></TD> ' + ' <TD WIDTH="296" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"><FONT COLOR="#FFFFCC"><INPUT TYPE="TEXT" NAME="Text4"' + ' SIZE="35" MAXLENGTH="35" VALUE="' + CompName[Ndx] + '"></FONT></TD> ' + ' </TR> ' + ' <TR VALIGN="MIDDLE"> ' + ' <TD WIDTH="160" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#000096"><B><FONT FACE="verdana,Arial,helvetica" SIZE="1"' + ' COLOR="#FFFFCC">Address</FONT></B></TD> ' + ' <TD WIDTH="9" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"></TD> ' + ' <TD WIDTH="296" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"><FONT COLOR="#FFFFCC"><INPUT TYPE="TEXT" NAME="Text5"' + ' SIZE="35" MAXLENGTH="35" VALUE="' + Address[Ndx] + '"></FONT></TD> ' + ' </TR> ' + ' <TR> ' + ' <TD WIDTH="160" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#000096"><B><FONT FACE="verdana,Arial,helvetica" SIZE="1"' + ' COLOR="#FFFFCC">Address2</FONT></B></TD> ' + ' <TD WIDTH="9" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"></TD> ' + ' <TD WIDTH="296" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"><FONT COLOR="#FFFFCC"><INPUT TYPE="TEXT" NAME="Text6"' + ' VALUE="' + Address2[Ndx] + '" SIZE="20" MAXLENGTH="30"></FONT></TD> ' + ' </TR> ' + ' <TR> ' + ' <TD WIDTH="160" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#000096"><B><FONT FACE="verdana,Arial,helvetica" SIZE="1"' + ' COLOR="#FFFFCC">Postcode</FONT></B></TD> ' + ' <TD WIDTH="9" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"></TD> ' + ' <TD WIDTH="296" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"><FONT COLOR="#FFFFCC"><INPUT TYPE="TEXT" NAME="Text7"' + ' SIZE="8" MAXLENGTH="8" VALUE="' + PoCode[Ndx] + '"></FONT></TD> ' + ' </TR> ' + ' <TR VALIGN="MIDDLE"> ' + ' <TD WIDTH="160" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#000096"><B><FONT FACE="verdana,Arial,helvetica" SIZE="1"' + ' COLOR="#FFFFCC">Telephone</FONT></B></TD> ' + ' <TD WIDTH="9" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"></TD> ' + ' <TD WIDTH="296" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"><FONT COLOR="#FFFFCC"><INPUT TYPE="TEXT" NAME="Text8"' + ' SIZE="35" MAXLENGTH="35" VALUE="' + CustTele[Ndx]+ '"></FONT></TD> ' + ' </TR> ' + ' <TR> ' + ' <TD WIDTH="160" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#000096"> </TD> ' + ' <TD WIDTH="9" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"> </TD> ' + ' <TD WIDTH="296" ALIGN="LEFT" VALIGN="MIDDLE"' + ' BGCOLOR="#FEF0D8"> </TD> ' + ' </TR> ' + ' </TABLE> </TD> ' + ' </TR> ' + ' </TABLE></FORM>'); document.close(); }